﻿using System.Security.Cryptography.X509Certificates;

namespace CSharpPro._0930;

public class Demo
{
    public int[] TestPrint1(int a, int b, int c)
    {
        int[] arr = { a, b, c };
        Array.Sort(arr);
        return arr;
    }

    public bool TestPrint2(int num)
    {
        return num % 7 != 0 && num / 10 % 7 != 0 && num % 10 != 7;
    }
    
    public void TestPrint3()
    {
        for (int i = 1; i <= 9 ; i++)
        {
            for (int j = 1; j <= i; j++)
            {
                Console.Write($"{j} * {i} = {j * i,2}  "); 
            }

            Console.WriteLine();
        }
    }

    public int TestPrint4(int num)
    {
        int sum = 1;
        for (int i = 2; i * i < num; i++)
        {
            if (num % i == 0)
            {
                sum += i;
                if (i != num / i)
                {
                    sum += num / i;
                }
            }
        }

        return num == 1 ? 0 : sum;
    }

    public int TestPrint5(int num)
      {
          if (num == 0)
          {
              return 1;
          }
          int count = 0;
          while (num>0)
          {
              num /= 10;
              count++;
          }
          return count;
      }
     
    public void TestPrint6(int num)
      {
          int mid = num / 2;
          for (int i = 0; i < num; i++)
          {
              int spaceCount = Math.Abs(mid - i); 
              for (int j = 0; j < spaceCount; j++)
              {
                  Console.Write(" ");
              }
              int starCount = 2 * (mid - spaceCount) + 1; 
              for (int k = 0; k < starCount; k++)
              {
                  Console.Write("*");
              }
              Console.WriteLine(); 
          }
      }
   
}